// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/user/api/SysMenuApi'

import ComClass from '@api/ComQuery'
import TreeClass from '@api/user/model/SysMenuDto'

const project = process.env.VUE_APP_PROJECT

const CLIENT = CORE.grpcCLIENT(Client)
const COM = [ComClass, 'comQuery']

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 结构树 —————————————————————————————— //

  async getTree(treeParam, TIP = '查询结构树') {
    const DTO = CORE.grpcDTO(TreeClass, treeParam, COM)
    const resp = await CORE.grpc(TIP, CLIENT, 'sysMenuTree', DTO)
    return resp.content || []
  },
  transTree(arr) {
    return arr.filter((item) => item.project === project)
  },
}
